<?php
error_reporting(0);
$isadmin=1;
include_once '../comm/config.php';
include '../comm/checkpostandget.php';
include '../comm/msgset.php';
include 'check.php';
$txstate=$_POST['txstate']; 
$txje=$_POST['txje']; 
$id=$_POST['id']; 
$why=$_POST['why']; 
$ddusername=$_POST['ddusername']; 
$sql="select email from ".$BIAOTOU."user where ddusername='".$ddusername."'";
$query=mysql_query($sql);
$emailarr=mysql_fetch_array($query);
$email=$emailarr['email'];

$q = "select * from ".$BIAOTOU."tixian where Id=".$id;
//echo $q;
$rs=mysql_query($q);
$num = mysql_num_rows($rs);
//echo $num;
if(!$num)
{
	echo "错误：未找到该记录！";
	exit;
}
else
{
	if($txstate=="0")
	{
		$q = "update ".$BIAOTOU."tixian set txstate=2 where id=".$id;
		mysql_query($q);
		$q = "update ".$BIAOTOU."user set money=money+".$txje.",txstate=0 where ddusername='".$ddusername."'";
		mysql_query($q);
		$sj= date("Y-m-d H:i:s");
		$msg_tixianfail=str_replace("[why]",$why,$msg_tixianfail);
		$insert = "INSERT into ".$BIAOTOU."msg(ddusername,title,content,addtime,senduser) values ('$ddusername','提现失败','".$msg_tixianfail."','$sj','网站客服')";
		mysql_query($insert);
		if(SMTPOPEN=='on' && TIXIANSENDEMAIL==1){
            mail_send($email, WEBTITLE.'提现通知', $msg_tixianfail);
        }
	}
	else
	{
		echo "该提现请求已经处理完毕，无法回退！<a href=tixianlist.php>返回</a>";
		exit;
	}
}
admin_log('退回提现');
header('Location: tixianlist.php');     

mysql_close();

?>
